#include "i386/kernel/timer.h"
#include "i386/kernel/screen.h"
#include "i386/arch_hooks.h"
#include "linux/jiffies.h"
#include "linux/interrupt.h"
#include "linux/stddef.h"

struct timer_opts *cur_timer = &timer_none;

u32 volatile jiffies = INITIAL_JIFFIES;

void __init time_init(void) {
  /*
    初始化时间
  xtime.tv_sec = get_cmod_time();
  xtime.tv_nesc =
  */

  cur_timer = &timer_pit;

  time_init_hook();
}

static inline void do_timer_interrupt(int irq, void* dev_id, struct pt_regs *reg) {
  // do_timer_interrupt_hook(regs);

  puts("timer");
}


irqreturn_t timer_interrupt(int irq, void* dev_id, struct pt_regs* reg) {
  /*
   * 
   */
  cur_timer->mark_offset();
  do_timer_interrupt(irq, NULL, reg);
  return IRQ_HANDLED;
}
